package cn.iocoder.yudao.module.booking.dal.mysql.courseinfo;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.booking.controller.admin.courseinfo.vo.CourseInfoPageReqVO;
import cn.iocoder.yudao.module.booking.dal.dataobject.courseinfo.CourseInfoDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 课程信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CourseInfoMapper extends BaseMapperX<CourseInfoDO> {

    default PageResult<CourseInfoDO> selectPage(CourseInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CourseInfoDO>()
                .eqIfPresent(CourseInfoDO::getTitle, reqVO.getTitle())
                .betweenIfPresent(CourseInfoDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(CourseInfoDO::getEndTime, reqVO.getEndTime())
                .likeIfPresent(CourseInfoDO::getInstructorName, reqVO.getInstructorName())
                .orderByDesc(CourseInfoDO::getId));
    }

    Integer updateAvailableNumberById(@Param("id") Long id,@Param("availableNumber") Long availableNumber );


}